(function(a) {
    a.fn.placeholder = function() {
        return this.each(function() {
            if (!("placeholder"in document.createElement(this.tagName.toLowerCase()))) {
                var b = a(this),c = b.attr("placeholder");
                !b.val() && b.val(c).data("color", b.css("color")).css("color", "#aaa");
                b.focus(
                        function() {
                            a.trim(b.val()) === c && b.val("").css("color", b.data("color"))
                        }).blur(function() {
                    a.trim(b.val()) || b.val(c).data("color", b.css("color")).css("color", "#aaa")
                })
            }
        })
    }
})(jQuery);
var cssTransitionsSupported = false;
(function() {
    var a = document.createElement("div");
    a.innerHTML = '<div style="-webkit-transition:color 1s linear;-moz-transition:color 1s linear;-o-transition:color 1s linear;-ms-transition:color 1s linear;-khtml-transition:color 1s linear;transition:color 1s linear;"></div>';
    cssTransitionsSupported = a.firstChild.style.webkitTransition !== void 0 || a.firstChild.style.MozTransition !== void 0 || a.firstChild.style.OTransition !== void 0 || a.firstChild.style.MsTransition !== void 0 || a.firstChild.style.KhtmlTransition !==
            void 0 || a.firstChild.style.Transition !== void 0;
    delete a
})();
$(document).ready(function() {
    $.tools.validator.fn("[type=time]", "Please supply a valid time", function(a, b) {
        return/^\d\d:\d\d$/.test(b)
    });
    $.tools.validator.fn("[data-equals]", "Value not equal with the $1 field", function(a) {
        var b = a.attr("data-equals"),c = this.getInputs().filter("[name=" + b + "]");
        return a.val() === c.val() ? true : [b]
    });
    $.tools.validator.fn("[minlength]", function(a, b) {
        var c = a.attr("minlength");
        return b.length >= c ? true : {en:"Please provide at least " + c + " character" + (c > 1 ? "s" : "")}
    });
    $.tools.validator.localizeFn("[type=time]",
    {en:"Please supply a valid time"});
    $().UItoTop({easingType:"easeOutQuart"});
    $(window).bind("load resize", function() {
        var a = $("#wrapper > section > section");
        a.css("position") == "absolute" && a.css("left") != 0 ? location.hash != "#menu" ? a.css("left", 0) : a.css("left", "100%") : a.show()
    });
    !location.href.match(/login\.html$/i) && (!location.hash || location.hash == "#menu") ? location.hash = $(".drilldownMenu .current a").attr("href") : $(window).trigger("hashchange");
    $("#wrapper > section > aside > nav").length && $("#wrapper > section > aside > nav").each(function() {
        $(this);
        $(this).drillDownMenu()
    });
    $(".showmenu").click(function() {
        $("#wrapper > section > section").animate({left:"100%"}, 300, "easeInOutQuart", function() {
            $(this).hide()
        })
    });
    $("input[placeholder]", ".login-box").placeholder();
    $("input[type=date]", ".login-box").dateinput();
    $("input:checkbox,input:radio,select,input:file", ".login-box").uniform();
    $(".has-validation", ".login-box").validator({position:"bottom left",offset:[5,0],messageClass:"form-error",message:"<div><em/></div>"}).attr("novalidate", "novalidate")
});
$(window).bind("drilldown", function() {
    $(".tabs > ul", "#main-content").tabs("section > section");
    $(".accordion", "#main-content").tabs(".accordion > section", {tabs:"header",effect:"slide",initialIndex:0});
    $("input[placeholder]", "#main-content").placeholder();
    $("input[type=date]", "#main-content").dateinput();
    $("input:checkbox,input:radio,select,input:file", "#main-content").uniform();
    $(".uploader .filename").click(function() {
        $("input:file", $(this).parent()).click()
    });
    $(".has-validation", "#main-content").validator({position:"bottom left",
        offset:[5,0],messageClass:"form-error",message:"<div><em/></div>"}).attr("novalidate", "novalidate");
    $(".message.closeable").each(function() {
        var a = $(this);
        a.prepend('<span class="message-close"></span>');
        $(".message-close", a).click(function() {
            a.fadeOut()
        })
    });
    $(".has-tooltip").tooltip({effect:"slide",offset:[-14,0],position:"top center",layout:"<div><em/></div>",onBeforeShow:function() {
        this.getTip().each(function() {
            $.browser.msie && PIE.attach(this)
        })
    },onHide:function() {
        this.getTip().each(function() {
            $.browser.msie &&
            PIE.detach(this)
        })
    }}).dynamic({bottom:{direction:"down",bounce:true}})
});
$(window).bind("hashchange", function() {
    if ((h = location.hash) && h != "#menu")link = h.replace(/^\#/, ""),id = link.replace(/[\/\.]/, "-"),$("#" + id).length && $("#" + id).remove(),$.ajax(link, {dataType:"html",cache:false,success:function(a) {
    //if ((h = location.hash) && h != "#menu")link = "views/" + h.replace(/^\#/, ""),id = link.replace(/[\/\.]/, "-"),$("#" + id).length && $("#" + id).removeVersion(),$.ajax(link, {dataType:"html",cache:false,success:function(a) {
        return pageDownloaded(a, id)
    },complete:function() {
    }})
});
function pageDownloaded(a, b) {
    var c = $('<div style="left: 100%" id="' + b + '">' + a + "</div>").appendTo($("#main-content"));
    title = $(c).find("h1.page-title").html();
    $("#wrapper > section > section > header h1").html(title);
    $("#wrapper > section > section").css("position") == "absolute" ? ($("> div:last", "#main-content").css({left:0,position:"relative"}).siblings().remove(),$("#wrapper > section > section").show().animate({left:0}, 300, "easeInOutQuart", function() {
        $(this).css("left", 0)
    })) : $("> div", "#main-content").animate({left:"-=100%"},
            "slow", "easeInOutQuart", function() {
                $(this).css("left", 0);
                $("> div:last", "#main-content").css({position:"relative"}).siblings().remove()
            });
    $(window).trigger("drilldown")
}
;
